<?php
class CommentController extends ApiController{
	public function save(){
		$author = request('author');
		$content = request('content');
		$department_id = request('department_id');
		if (empty($author) || empty($content) || empty($department_id)) {
			$this->error('202', '请把所有项目填写完整');
		}
		if (mb_strlen($content, 'utf8')>200){
			$this->error(202, '留言内容长度不得超过200个字符');
		}
		$data = array(
			'author'	=> $author,
			'content'	=> $content,
			'department_id'	=> $department_id,
			'pubtime'	=> time()
		);
		if (CommentModel::add($data)){
			$this->success(array());
		}else{
			$this->error(202, '服务器繁忙，请稍候尝试！');
		}
	}
}